﻿Namespace EIBData.DPT
    Public NotInheritable Class EIBDataDPT_2_001
        Inherits EIBDataDPT_2_Base

        Private _value As EIBDataDPT_1_001 = Nothing

        Sub New(data As Byte())
            MyBase.New(data)

            _value = New EIBDataDPT_1_001(_valueBase)
        End Sub

        Sub New(control As Boolean, value As EIBDataDPT_1_001)
            MyBase.New(control, value.ToObject(0))
        End Sub


        Public Shared Shadows ReadOnly Property DPT_Name As String
            Get
                Return "DPT_Switch_Control"
            End Get
        End Property

        Public Shared Shadows ReadOnly Property DPT_Number As String
            Get
                Return "2.001"
            End Get
        End Property

        Public Overrides Function ToString() As String
            If _control Then
                Return String.Format("Control: {0}", _value.ToString)
            Else
                Return "No control"
            End If
        End Function

        Public Overrides Function ToObject() As Object()
            Return New Object() {_control, _value}
        End Function

        Public Overrides ReadOnly Property ObjectType As System.Type()
            Get
                Return New Type() {GetType(Boolean), GetType(EIBDataDPT_1_001)}
            End Get
        End Property

        Public Overrides Function ToInfoList() As List(Of EIB.InfoBase)
            Dim list As New List(Of EIB.InfoBase)

            list.Add(New EIB.Info("Type", DPT_Name))
            list.Add(New EIB.Info("Control", _control))
            list.Add(New EIB.Info("Value", _value.ToString))

            Return list
        End Function
    End Class
End Namespace